import celery
import time
import redis # 需要配置此环境

# Redis数据库为0-15（共16个）
backend = 'redis://127.0.0.1:6379/1'    # 终端数据使用Redis数据库1存储
broker = 'redis://127.0.0.1:6379/2'     # 代理数据使用Redis数据库2存储
cel = celery.Celery('test', backend=backend, broker=broker)


@cel.task
def send_email(name):
    print("向%s发送邮件..." % name)
    time.sleep(3)
    print('向%s发送邮件完成' % name)
    return "OK"


@cel.task
def send_phone(name):
    print("向%s打电话..." % name)
    time.sleep(3)
    print('向%s打电话完成' % name)
    return "OK"
